<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/axios.min.js"></script>
    <script>

        window.onload = function () {

            // checkUser();
        }


        function checkUser() {
            axios.get("/user/login").then(resp => {
                var loginUser = resp.data;
                alert(loginUser);
                if (loginUser == null) {
                    $("loginDiv").innerHTML = `你好！请先<a href="login.html">登陆</a>`;
                } else {
                    $("loginDiv").innerHTML = `欢迎光临  ${loginUser.username}`;
                }
            })
        }


        function $(id) {
            return document.getElementById(id);
        }
    </script>


</head>
<body>
<div id="loginDiv"></div>

</body>
</html>